#ifndef __MegaMan_h__
#define __MegaMan_h__

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Macro definitions
// Bit shift magic
#define getRightN(pixelByte) (pixelByte & 0x0F)
#define getLeftN(pixelByte) (pixelByte >> 4 & 0x0F)

#define setRightN(buffer,pixelByte) buffer = (buffer & 0xF0 | (pixelByte & 0x0F))
#define setLeftN(buffer,pixelByte) buffer = (buffer & 0x0F| (pixelByte << 4 & 0xF0))
  
#define joinNibbles(pixelByte,lsbPixel,msbPixel) pixelByte = (lsbPixel & 0x0F| msbPixel << 4 & 0xF0)

/* from AVR035: Efficient C Coding for AVR */

/* a=register, b=bit number to act upon */
#define BIT_SET(a,b) ((a) |= (1<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
#define BIT_CHECK(a,b) ((a) & (1<<(b)))

/* x=target variable, y=mask */
#define BITMASK_SET(x,y) ((x) |= (y))
#define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
#define BITMASK_FLIP(x,y) ((x) ^= (y))
#define BITMASK_CHECK(x,y) ((x) & (y))



void imageFromFlash(char *);
void updateBuffer(uint8_t *);
void alterBuffer(char *, char *);
void sendBuffer(uint8_t *);
void putPixel(uint8_t, uint8_t, uint8_t);

extern boolean abortFlag;

#endif /* __MegaMan_h__ */
